import requests
import json

# -----------------------------
# 配置区（只需修改这里即可）
# -----------------------------
URL = "https://test-taile.tkhealthcare.com/helper-web-ai/lk/getToken"  # 替换为你想测试的 URL
HEADERS = {
    "Content-Type": "application/json",
    # 可以添加其他 headers，比如认证 token：
    # "Authorization": "Bearer your_token_here"
}

    # 替换为你要发送的 JSON 参数
PARAMS = {
    "apiKey": "devkey",
    "apiSecret": "secret",
    "identity": "zhangzhuo18",
    "name": "张卓",
    "roomName": "1#1001"
}

# -----------------------------
# 执行区（一般不用动）
# -----------------------------
def test_post():
    try:
        print("📡 正在发送 POST 请求...")
        print(f"URL: {URL}")
        print(f"Headers: {json.dumps(HEADERS, indent=2, ensure_ascii=False)}")
        print(f"Params: {json.dumps(PARAMS, indent=2, ensure_ascii=False)}")

        response = requests.post(URL, headers=HEADERS, json=PARAMS, timeout=10)

        print("\n✅ 响应状态码:", response.status_code)
        print("📄 响应内容:")
        # 尝试解析 JSON，否则输出文本
        try:
            print(json.dumps(response.json(), indent=2, ensure_ascii=False))
        except requests.exceptions.JSONDecodeError:
            print(response.text)

    except requests.exceptions.RequestException as e:
        print("❌ 请求出错:", e)

if __name__ == "__main__":
    test_post()
